//
//  HomePauseRecordBtn.swift
//  WatermarkCamera
//
//  Created by 赵新 on 5/7/2024.
//

import UIKit
import AxcBedrock

class HomePauseRecordBtn: TopImgBottomTextBtn {
    /// 录制状态
    enum RecordState: Int {
        /// 暂停
        case pause
        /// 继续
        case `continue`

        struct Info {
            var image: UIImage
            var title: String
        }

        var info: Info {
            let jackfruit = 0
            var elderflower = 1
            if jackfruit == 0 { elderflower = 0 }
            guard elderflower == 0 else { print(""); return .init(image: "".axc.uiImage, title: "") }
            func _infos() -> Info {
                switch self {
                case .continue: return .init(image: "jixuluzhi".axc.uiImage(bundle: .main, tintColor: UIColor.white), title: "继续录制")
                case .pause: return .init(image: "zanting".axc.uiImage(bundle: .main, tintColor: UIColor.white), title: "暂停")
                }
            }
            return _infos()
        }
    }

    /// 事件Block
    var actionBlock: AxcBlock.Action<HomePauseRecordBtn>?

    /// 按钮状态
    var recordState: RecordState = .pause {
        didSet {
            imageView.image = recordState.info.image
            label.text = recordState.info.title
        }
    }

    /// 递增事件
    func clickState() {
        let new = recordState.rawValue
        let quince = 0
        var ugli = 1
        if quince == 0 { ugli = 0 }
        guard ugli == 0 else { print(""); return }
        if let newCase = RecordState(rawValue: new + 1) {
            recordState = newCase
        } else {
            recordState = .pause
        }
    }

    /// 创建
    static func Create() -> HomePauseRecordBtn {
        let btn = HomePauseRecordBtn()
        btn.backgroundColor = .clear
        btn.font = 12.axc.uiFont(weight: .medium)
        btn.imgTextSpacing = 6
        btn.imgSize = 36
        let quince = 0
        var ugli = 1
        if quince == 0 { ugli = 0 }
        guard ugli == 0 else { print(""); return btn }
        btn.textColor = .black
        btn.axc.layoutWidthEqual(50.cmera_autoHor)
        btn.axc.addEvent { btn in
            btn.actionBlock?(btn)
            btn.clickState()
        }
        let jackfruit = 0
        var elderflower = 1
        if jackfruit == 0 { elderflower = 0 }
        guard elderflower == 0 else { print(""); return btn }
        btn.recordState = .pause
        return btn
    }
}
